package br.edu.ufcg.lsd.wbis.control.util.matching;

/**
 * @author Renato Miceli
 */
public abstract class AbstractMatcher {

	protected boolean matches(String value, StringMatcher searchMatcher, String comparableValue) {
		if (!isMatcheable(searchMatcher)) {
			return true;
		}

		return searchMatcher.matches(value, comparableValue);
	}

	protected boolean matches(Boolean value, Boolean comparableValue) {
		if (!isMatcheable(value) || !isMatcheable(comparableValue)) {
			return true;
		}

		return value.equals(comparableValue);
	}

	protected boolean isMatcheable(Object value) {
		return (value != null);
	}

}
